package com.foreveross.taskservice.core.domain.task.assign.impl;

import java.util.ArrayList;
import java.util.List;

import org.springframework.stereotype.Component;

import com.foreveross.taskservice.core.domain.task.TaskQueueRecordEntity;
import com.foreveross.taskservice.core.domain.task.TaskTemplateAssignDayEntity;
import com.foreveross.taskservice.core.domain.task.TaskTemplateEntity;
import com.foreveross.taskservice.core.domain.task.assign.AssignBuildQueue;
import com.foreveross.taskservice.infra.util.DateUtil;

@Component("fixedAssignBuildQueue")
public class FixedTimeBuildQueueBean implements AssignBuildQueue {

	@Override
	public List<TaskQueueRecordEntity> build(TaskTemplateAssignDayEntity ta) {
		List<TaskQueueRecordEntity> list = new ArrayList<TaskQueueRecordEntity>();
		TaskTemplateEntity template = ta.getTemplate();
		list.add(new TaskQueueRecordEntity(
				template.getFromCity(), template.getFromCityName(), template.getToCity(), template.getToCityName(),
				DateUtil.getDateAfter(ta.getAssignFlightDay()), 
				DateUtil.getDateAfter(ta.getAssignFlightDay()+ta.getAssignRoundDay()),
				template.getIsInternational()==null?0:template.getIsInternational().intValue(), template.getIsReturn()==null?0:template.getIsReturn(), 
								template.getGrabChannelId(), template.getGrabChannel(), template.getAreaCode(), template.getAreaName(), template.getAttachHbaseKey(), template.getPriority()));
		return list;
	}

}
